<template>
  <view class="container">
    <scroll-view scroll-y="true" style="width: 100%; height: 100vh">
      <view class="item" v-for="item in list" :key="item.id">
        <!-- 评分 -->
        <view class="header">
          <image :src="imgUrl + item.avatar" mode="aspectFill" style="width: 60rpx; height: 60rpx; border-radius: 100rpx"></image>
          <view style="margin: 0 16rpx 0 18rpx; font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: bold; color: #222222">{{ item.username }}</view>
          <uni-rate allow-half :value="item.star" readonly size="20" color="#666666" activeColor="#F34915" :isFill="false" />
        </view>
        <!-- 评价 -->
        <view class="pingjia">{{ item.content }}</view>
        <view class="date">{{ item.grade_name + item.subject_name + '-' + item.createtime }}</view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import dayjs from 'dayjs';
export default {
  data() {
    return {
      list: [],
      imgUrl: ''
    };
  },
  methods: {
    // 获取评价列表
    async getlist() {
      const res = await uni.$http.post('/evaluates/list', {
        type: '2'
      });
      console.log('列表', res);
      this.list = res.data.data.list;
      this.list.forEach((item) => {
        item.createtime = dayjs(item.createtime * 1000).format('YYYY-MM-DD ');
      });
    }
  },
  onLoad() {
    this.imgUrl = this.imgurl;
    this.getlist();
  }
};
</script>

<style lang="scss" scoped>
.container {
  box-sizing: border-box;
  .item {
    box-sizing: border-box;
    width: 710rpx;
    height: 254rpx;
    margin: 20rpx;
    padding: 20rpx 30rpx;
    background: #ffffff;
    border-radius: 20rpx 20rpx 20rpx 20rpx;
    border: 2rpx solid #f1f1f1;
    .header {
      display: flex;
      align-items: center;
    }
    .pingjia {
      box-sizing: border-box;
      width: 616rpx;
      height: 80rpx;
      margin: 20rpx 0rpx 10rpx 0rpx;
      font-size: 28rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: #333333;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .date {
      display: flex;
      justify-content: flex-end;
      font-size: 24rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: #666666;
    }
  }
}
</style>
<style>
page {
  background-color: #f9f9f9;
}
</style>
